package win.acfelis.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import win.acfelis.service.AdverService;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 首页管理
 * 刘柱
 * 20181230 1825
 */
@Controller
@RequestMapping("/")
public class IndexController {

    @Resource
    private AdverService adverService;

    /**
     * 首页
     *
     * @param model 根据分类返回数据
     * @return 返回数据
     */
    @RequestMapping("")
    public String index(Model model) {
        //获取信息
        Map<String, List<Map<String, Object>>> result = adverService.getInfo();
        model.addAttribute("top", result.get("top"));
        model.addAttribute("tommorrow", result.get("tommorrow"));
        model.addAttribute("yesterday", result.get("yesterday"));
        model.addAttribute("acquired", result.get("acquired"));
        model.addAttribute("tomm", result.get("time").get(0).get("tomm"));
        model.addAttribute("acqu", result.get("time").get(0).get("acqu"));
        model.addAttribute("yest", result.get("time").get(0).get("yest"));
        return "index/index";
    }
}
